package com.xcity.game.item.listener;

import com.xcity.db.entity.Player;
import com.xcity.game.item.ItemTemplate;
import com.xcity.game.item.drop.listener.ItemDropListener;
import com.xcity.pomelo.push.msg.BatchItemsPush;

public class DefaultBagListener implements ItemDropListener {
	
	private BatchItemsPush packet;
	
	public DefaultBagListener() {
	}
	
	@Override
	public void itemAdded(ItemTemplate item, int count) {
		if (packet == null) {
			packet = new BatchItemsPush();
		}
		packet.add(item, count);
	}

	@Override
	public void itemRemoved(ItemTemplate item, int count) {
	}
	
	public void end(Player player) {
		if (packet != null) {
			player.send(packet);
		}
	}
	
	@Override
	public void itemDroped(Player player, int itemId, int count) {
	}
	
	public BatchItemsPush getPacket() {
		return packet;
	}
	
	public int size() {
		return packet != null && packet.getList() != null ? packet.getList().size() : 0;
	}

}
